package leetcode.backtrace;

import leetcode.backtrace.common.BackTraceUtils;
import leetcode.tree.common.TreeNode;
import leetcode.tree.common.TreeUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution95 {
    public List<TreeNode> generateTrees(int n) {
        // todo 不同的二叉搜索树
        return BackTraceUtils.generateTrees(n);
    }
}

public class leetcode95 {
    public static void main(String[] args) {
        Solution95 solution95 = new Solution95();
        test95(solution95, 3);
        test95(solution95, 1);
    }

    private static void test95(Solution95 solution95, int n) {
        List<TreeNode> nodeList = solution95.generateTrees(n);
        List<List<Integer>> result = new ArrayList<>();
        for(int i = 0; i< nodeList.size(); i++){
            List<Integer> vals = TreeUtils.getLeetcodeTreeVals(nodeList.get(i));
            result.add(vals);
        }
        System.out.println(result);
    }
}
